(function(window){
	var global = {
		storage :{
	        addItem: function (key, value) {
	            let s_key = key;
	            if (typeof (window.localStorage)) { window.localStorage.setItem(s_key, value); } else { }
	        },
	        removeAllItem: function () {
	            if (typeof (window.localStorage)) { 
	                for (i = window.localStorage.length-1; i >-1; i--) {
	                    var aKeyName = window.localStorage.key(i);
	                    window.localStorage.removeItem(aKeyName)
	                }
	            } else {  
	            }
	        },
	        getItem: function (key) {
	            if (typeof (window.localStorage)) { return window.localStorage.getItem(key); } else { }
	        },
	        removeItem: function (key) { 
	            if (typeof (window.localStorage)) {  window.localStorage.removeItem(key); } else {  }
	        },
	        updateItem: function (key, value) {
	            if (typeof (window.localStorage)) { window.localStorage.removeItem(key); window.localStorage.setItem(key, value); } else {  }
	        }
		},
	    //浏览器属性
        browser : {
            versions: function() {
                var u = navigator.userAgent, app = navigator.appVersion;
                return {
                    trident: u.indexOf('Trident') > -1, 
                    presto: u.indexOf('Presto') > -1, 
                    webKit: u.indexOf('AppleWebKit') > -1,
                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,
                    mobile: !!u.match(/AppleWebKit.*Mobile.*/), 
                    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), 
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, 
                    iPhone: u.indexOf('iPhone') > -1, 
                    iPad: u.indexOf('iPad') > -1, 
                    webApp: u.indexOf('Safari') == -1,
                    chrome: u.indexOf('Chrome') > -1
                };
            } (),
            language: (navigator.browserLanguage || navigator.language).toUpperCase()
        },
        language:{
        	getCustomerLanguage(){
        		let lang = global.storage.getItem("LANG");
        		if(!lang)
        			lang = global.browser.language;

        		return lang;
        	},
        	setCustomerLanguage(language){
        		global.storage.addItem("LANG",language);
        	}
        },
        CONST:{
        	LANG_CN: "ZH-CN",
        	LANG_EN: "EN"
        }
    };
    window.G = global;
}(window));
